<?php
/**
 * Get authenticated user view helper
 * Use this view helper to retrieve the currently authenticated user from within
 * the view.
 *
 * @package 	Visi
 * @subpackage 	View Helpers
 * @author 		Luke Visinoni <luke.visinoni@gmail.com>
 * @copyright 	(c) 2011 Coalition Technologies <joel@coalitiontechnologies.com>
 * @version 	$Id$
 */
class Visi_View_Helper_GetAuthUser extends Zend_View_Helper_Abstract {

    static protected $_user = false;
    
    public function getAuthUser() {
    
        if (!self::$_user) {
            if (Zend_Auth::getInstance()->hasIdentity()) {
                $user = Zend_Auth::getInstance()->getIdentity();
                $catalog = Zend_Controller_Action_HelperBroker::getExistingHelper('ModelCatalog');
                $userTbl = $catalog->direct('user');
                self::$_user = $userTbl->fetchRow($userTbl->select()->where("user_id = ?", $user->user_id));
            }
        }
        return self::$_user;
    
    }

}